package cn.highset.modules.base.controller.api;

import cn.highset.base.ApiBaseController;
import cn.highset.common.annotation.IgnoreAuth;
import cn.highset.common.utils.PageUtil;
import cn.highset.common.utils.ResultUtil;
import cn.highset.common.vo.PageVo;
import cn.highset.common.vo.Result;
import cn.highset.common.vo.SearchVo;
import cn.highset.modules.base.entity.Video;
import cn.highset.modules.base.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类 描 述：API 视频信息
 * 创建时间：2019-06-15 10:32
 * 创 建 人：victor
 */
@Slf4j
@RestController
@Api(description = "API 视频信息")
@RequestMapping("/api/video")
@Transactional
public class ApiVideoController extends ApiBaseController {
    @Autowired
    private VideoService videoService;

    /**
     * @name: 获取视频列表
     * @description: TODO
     * @return:
     * @date: 2019-06-15 10:41
     * @auther: victor
     */
    @IgnoreAuth
    @PostMapping("list")
    @ApiOperation(value = "多条件分页获取视频")
    public Result<Page<Video>> getByCondition(@ModelAttribute Video video,
                                              @ModelAttribute SearchVo searchVo,
                                              @ModelAttribute PageVo pageVo) {
        Page<Video> page = videoService.findByCondition(video, searchVo, PageUtil.initPageOrderMore(pageVo));
        return new ResultUtil<Page<Video>>().setData(page);
    }

}
